<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .clickcolor {
            color: #f4c2e3;
        }
    </style>
</head>

<body>
    <div id="app">
        <h1>{{message}}</h1>
        <ul v-for="(item,index) in musices" @click="clickmusic(index)" :class="{clickcolor:index===nowindex}">
            <li>{{item}}</li>
        </ul>
    </div>
    <script src="https://unpkg.com/vue@next"></script>
    <script>
        //用vue创建app
        const app = Vue.createApp({
            // template: `

            // `,
            data() {
                return {
                    message: "Hello world",
                    musices: ["晴天", "稻香", "七里香"],
                    nowindex: 0
                }
            },
            methods: {
                clickmusic(index) {
                    this.nowindex = index
                }
            }
        })
        //挂载app
        app.mount("#app")
    </script>

</body>

</html>